PDFTriage-Question Answering over Long, Structured Documents

随着大规模对话模型的蓬勃发展,越来越多从文档中检索信息回复用户问题的需求出现。
在以往的RAG中,PDF类型的文档通常被看作为纯文本使用,使得模型总结回复的过程中无法获取到PDF中文本以外的内容。
本文主要有三点贡献:

  • 将PDF文档视为结构化对象而非纯文本;
  • release一份数据集
  • 提出一种提示模型的方法

PDFTriage回复用户问题包括3个步骤:

  1. 生成document metadata
  2. 使用LLM从文档中筛选出相关内容
  3. 基于检索到的内容生成回复

生成document metadata

使用Adobe Extract API将PDF转换为类似HTML的树结构,可以从中获取到章、节、标题、表、图、段落等,作者将解析出的信息以JSON格式存储。

LLM筛选相关内容

作者设计了fetch_pages、fetch_Sections、fetch_table,fetch_figure和retrieve等方法。

Function : Description
fetch_pages : Get the text contained in the pages listed.
fetch_sections : Get the text contained in the section listed.
fetch_figure : Get the text contained in the figure caption listed.
fetch_table : Get the text contained in the table caption listed.
retrieve : Issue a natural language query over the document, and fetch relevant chunks.
这些方法通过GPT的Function Calling调用,得到的结果会被写入进Prompt当中。

生成回复

Prompt如下:

You are an expert document question answering system. You answer questions by finding relevant content in > the document and answering questions based on that content.
Document : (texual metadata of document)

方法大概就是这样了。